package logic

import (
	"context"
	"group/common"
	"group/models"

	"group/internal/svc"
	"group/pb/group"

	"github.com/zeromicro/go-zero/core/logx"
)

type DeleteGroupLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewDeleteGroupLogic(ctx context.Context, svcCtx *svc.ServiceContext) *DeleteGroupLogic {
	return &DeleteGroupLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

// DeleteGroup 解散群聊
func (l *DeleteGroupLogic) DeleteGroup(in *group.GroupInfo) (*group.Empty, error) {
	err := l.svcCtx.ChatGroupModel.Update(l.ctx, &models.ChatGroup{
		Id:     in.Id,
		Status: common.GroupStatusDelete,
	})
	if err != nil {
		return nil, err
	}
	return &group.Empty{}, nil
}
